package com.usian.common.exception;

import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice//监听controller层及往下的异常
@Log4j2
public class ExceptionConfiguration {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResponseResult exception(Exception e){
       log.error("此处是通用异常统一处理模块");
       return  ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }
}
